package data;

import java.util.ArrayList;
import java.util.HashMap;

public class Unary implements Constraint{
	public enum UnaryType {
		Inclusive,
		Exclusive;
	}
	
	public UnaryType Type;
	public Item Variable;
	public ArrayList<Bag> Values;
	
	public Unary(UnaryType type, Item variable, ArrayList<Bag> values) {
		Type = type;
		Variable = variable;
		Values = values;
	}
	
	public boolean IsSatisfied() {
		switch (Type) {
		case Inclusive:
			for (int i = 0; i < Variable.Domain.size(); i++) {
				if (!Values.contains(Variable.Domain.get(i))) {
					return false;
				}
			}
			return true;
		case Exclusive:
			for (int i = 0; i < Values.size(); i++) {
				if (Variable.Domain.contains(Values.get(i))) {
					return false;
				}
			}
			return true;
		default:
			return false;
		}
	}

	@Override
	public boolean IsSatisfied(HashMap<Item, Bag> assignments) {
		return IsSatisfied();
	}
}
